/**
 * Create by CaoWenjian
 *
 * @copyRight: 2018
 **/
package com.bjboot.caocao.system.service.impl;

import com.bjboot.caocao.common.utils.Query;
import com.bjboot.caocao.system.dao.LogMapper;
import com.bjboot.caocao.system.domain.LogDO;
import com.bjboot.caocao.system.domain.PageDO;
import com.bjboot.caocao.system.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *@Description ${description}
 *@Author 操文健
 *@Date 2018-09-19 下午2:56
 *@Version 1.0
 **/
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    // 异步处理日志插入，加快系统相应速度
    @Async
    @Override
    public void save(LogDO logDO) {
        logMapper.insertSelective(logDO);
    }

    @Override
    public PageDO<LogDO> queryList(Query query) {
        int total = logMapper.count(query);
        List<LogDO> logs = logMapper.list(query);
        PageDO<LogDO> page = new PageDO<>();
        page.setTotal(total);
        page.setRows(logs);
        return page;
    }

    @Override
    public int remove(Long id) {
        return logMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int batchRemove(Long[] ids) {
        return logMapper.batchRemove(ids);
    }
}
